package cloud.shyidong.system.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

@RestController
public class UserController {

    @Value("${system.version:v1}")
    private String version;

    @GetMapping("/user/list")
    public Map<String, Object> userList() {
        Map<String, Object> result = new LinkedHashMap<>();
        List<Map<String, String>> userList = new ArrayList<>();
        Map<String, String> user1 = new LinkedHashMap<>();
        user1.put("name", "ZhangSan");
        user1.put("age", "16");
        if ("v1".equals(version)) {
            user1.put("sex", "0");
        }
        userList.add(user1);
        Map<String, String> user2 = new LinkedHashMap<>();
        user2.put("name", "LiSi");
        user2.put("age", "18");
        if ("v1".equals(version)) {
            user2.put("sex", "1");
        }
        userList.add(user2);
        Map<String, String> user3 = new LinkedHashMap<>();
        user3.put("name", "WangWu");
        user3.put("age", "20");
        if ("v1".equals(version)) {
            user3.put("sex", "0");
        }
        userList.add(user3);
        result.put("code", 0);
        result.put("data", userList);
        return result;
    }

}
